package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.InroomActModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by hyp on 2016/11/29.
 */
@Transactional
public interface InroomActRepository extends JpaRepository<InroomActModel, Integer>, JpaSpecificationExecutor<InroomActModel> {

    @Modifying
    @Query("update InroomActModel a set a.actId=?2,a.actName=?3 where a.id=?1")
    int updateById(Integer id, Integer actId, String actName);

    @Query("select a from InroomActModel a where a.inroomId=?1 order by a.id desc")
    List<InroomActModel> findByRoomId(Integer roomId);
}
